package com.umeng.analytics.pro;

import android.content.Context;
import android.text.TextUtils;

public class bg implements az {
    private boolean a;
    private int b;
    private int c;
    private int d;
    private float e;
    private float f;
    private String g;
    private Context h;
    private static bg i;

    static {
        bg.i = null;
    }

    private bg(Context arg5, String arg6, int arg7) {

        this.a = false;
        this.b = -1;
        this.c = -1;
        this.d = -1;
        this.e = 0f;
        this.f = 0f;
        this.g = null;
        this.h = null;
        this.h = arg5;
        this.a(arg6, arg7);
    }

    public static boolean a(String arg7) {
        int v6 = 5;
        boolean v0 = false;
        if (!TextUtils.isEmpty(((CharSequence) arg7))) {
            String[] v2 = arg7.split("\\|");
            if (v2.length == 6) {
                if ((v2[0].startsWith("SIG7")) && v2[1].split(",").length == v2[v6].split(",").length) {
                    return true;
                }

                if (!v2[0].startsWith("FIXED")) {
                    return v0;
                }

                int v3 = v2[v6].split(",").length;
                int v2_1 = Integer.parseInt(v2[1]);
                if (v3 < v2_1) {
                    return v0;
                }

                if (v2_1 <= 0) {
                    return v0;
                }

                v0 = true;
            }
        }

        return v0;
    }

    public static bg a(Context arg4) {
        bg v0_2;
        Class v1 = bg.class;
        synchronized (v1) {
            if (bg.i == null) {
                af.a v0_1 = af.a(arg4).b();
                bg.i = new bg(arg4, v0_1.f(null), v0_1.d(0));
            }

            v0_2 = bg.i;
        }
        return v0_2;
    }

    public boolean a() {
        return this.a;
    }

    public void a(af.a arg3) {
        this.a(arg3.f(null), arg3.d(0));
    }

    public void a(String arg4, int arg5) {
        this.c = arg5;
        String v0 = aa.a(this.h);
        if (!TextUtils.isEmpty(((CharSequence) v0)) && !TextUtils.isEmpty(((CharSequence) arg4))) {
            int v1 = 12;
            try {
                this.e = this.b(v0, v1);
                this.f = this.b(v0, 6);
                if (arg4.startsWith("SIG7")) {
                    this.b(arg4);
                } else if (arg4.startsWith("FIXED")) {
                    this.c(arg4);
                } else {
                }
            } catch (Exception v0_1) {
                this.a = false;
                by.e("v:" + arg4, ((Throwable) v0_1));
            }
        } else {
            this.a = false;
        }
    }

    public int b() {
        return this.b;
    }

    private float b(String arg3, int arg4) {
        int v0 = arg4 << 1;
        float v0_1 = arg3 == null ? 0f : (((float) Integer.valueOf(arg3.substring(v0, v0 + 5), 16).intValue())) / 1048576f;
        return v0_1;
    }

    private void b(String arg11) {
        String[] v6;
        int v9 = 4;
        int v5 = -1;
        if (arg11 != null) {
            String[] v4 = arg11.split("\\|");
            float v0 = v4[2].equals("SIG13") ? Float.valueOf(v4[3]).floatValue() : 0f;
            if (this.e > v0) {
                this.a = false;
                return;
            }

            float[] v0_1 = null;
            if (v4[0].equals("SIG7")) {
                v6 = v4[1].split(",");
                float[] v3 = new float[v6.length];
                int v0_2;
                for (v0_2 = 0; v0_2 < v6.length; ++v0_2) {
                    v3[v0_2] = Float.valueOf(v6[v0_2]).floatValue();
                }

                v0_1 = v3;
            }

            int[] v3_1 = null;
            if (v4[v9].equals("RPT")) {
                this.g = "RPT";
                v6 = v4[5].split(",");
                int[] v4_1 = new int[v6.length];
                int v3_2;
                for (v3_2 = 0; v3_2 < v6.length; ++v3_2) {
                    v4_1[v3_2] = Integer.valueOf(v6[v3_2]).intValue();
                }

                v3_1 = v4_1;
            } else {
                if (v4[v9].equals("DOM")) {
                    this.a = true;
                    this.g = "DOM";
                    int v6_1 = 5;
                    try {
                        v6 = v4[v6_1].split(",");
                        v3_1 = new int[v6.length];
                        int v4_3;
                        for (v4_3 = 0; v4_3 < v6.length; ++v4_3) {
                            v3_1[v4_3] = Integer.valueOf(v6[v4_3]).intValue();
                        }
                    } catch (Exception v4_2) {
                    }
                }
            }
            float v4_4 = 0f;
            int v1 = 0;
            while (true) {
                if (v1 < v0_1.length) {
                    v4_4 += v0_1[v1];
                    if (this.f >= v4_4) {
                        ++v1;
                        continue;
                    }
                } else {
                    v1 = v5;
                }
                break;
            }
            if (v1 != v5) {
                this.a = true;
                this.d = v1 + 1;
                if (v3_1 == null) {
                    return;
                }

                this.b = v3_1[v1];
            } else {
                this.a = false;
            }
        }
    }

    private void c(String arg11) {
        String[] v5;
        int v9 = 5;
        int v8 = 4;
        int v1 = -1;
        if (arg11 != null) {
            String[] v4 = arg11.split("\\|");
            float v0 = 0f;
            if (v4[2].equals("SIG13")) {
                v0 = Float.valueOf(v4[3]).floatValue();
            }

            if (this.e > v0) {
                this.a = false;
                return;
            }

            int v0_1 = v4[0].equals("FIXED") ? Integer.valueOf(v4[1]).intValue() : v1;
            int[] v2 = null;
            if (v4[v8].equals("RPT")) {
                this.g = "RPT";
                v5 = v4[v9].split(",");
                int[] v4_1 = new int[v5.length];
                int v2_1;
                for (v2_1 = 0; v2_1 < v5.length; ++v2_1) {
                    v4_1[v2_1] = Integer.valueOf(v5[v2_1]).intValue();
                }

                v2 = v4_1;
            } else {
                if (v4[v8].equals("DOM")) {
                    this.g = "DOM";
                    this.a = true;
                    int v5_1 = 5;
                    try {
                        v5 = v4[v5_1].split(",");
                        v2 = new int[v5.length];
                        int v4_3;
                        for (v4_3 = 0; v4_3 < v5.length; ++v4_3) {
                            v2[v4_3] = Integer.valueOf(v5[v4_3]).intValue();
                        }
                    } catch (Exception v4_2) {
                    }
                }
            }
            if (v0_1 != v1) {
                this.a = true;
                this.d = v0_1;
                if (v2 == null) {
                    return;
                }

                this.b = v2[v0_1 - 1];
            } else {
                this.a = false;
            }
        }
    }

    public int c() {
        return this.c;
    }

    public int d() {
        return this.d;
    }

    public String e() {
        String v0 = !this.a ? "error" : String.valueOf(this.d);
        return v0;
    }

    public String f() {
        return this.g;
    }

    public String toString() {
        return " p13:" + this.e + " p07:" + this.f + " policy:" + this.b + " interval:" + this.c;
    }
}

